package com.xbs.dao.enterprise;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.xbs.dao.conn.BaseDao;
import com.xbs.dao.conn.ParamSet;
import com.xbs.dao.conn.RowDatas;
import com.xbs.entity.EpOrderDetailEntity;

public class EpOrderDetailDao extends BaseDao{
	/**
	 * 根据订单编号查询订单详情
	 */
	public List<EpOrderDetailEntity> getOrderDetailById(String id){
		String sql="select 	o.eo_order_id,ep.enterprise_id,ep.enterprise_name,o.eo_reserve_get_time,o.eo_fact_return_time,o.eo_order_status,o.eo_rent_type,c.car_model_name,m.car_model_number,m.rent_money,c.car_model_type,c.car_model_seating,c.car_model_door_number,c.car_model_fuel_type,c.car_model_image,c.company_discount "+
					"from tb_enterprise ep,tb_enterprise_order o,tb_enterprise_model m,tb_car_model c "+
					"where ep.enterprise_id=o.eo_account and o.eo_order_id=m.eo_order_id and c.car_model_id=m.car_model_id and m.eo_order_id=?";

		RowDatas<EpOrderDetailEntity> rd=new RowDatas<EpOrderDetailEntity>() {
			
			@Override
			public EpOrderDetailEntity getRowData(ResultSet rs) throws SQLException {
				EpOrderDetailEntity ep=new EpOrderDetailEntity();
				ep.setEo_order_id(rs.getString("eo_order_id"));
				ep.setEp_account(rs.getString("enterprise_id"));
				ep.setEnterprise_name(rs.getString("enterprise_name"));
				ep.setEo_reserve_get_time(rs.getDate("eo_reserve_get_time"));
				ep.setEo_fact_return_time(rs.getDate("eo_fact_return_time"));
				ep.setEo_order_status(rs.getString("eo_order_status"));
				ep.setEo_rent_type(rs.getInt("eo_rent_type"));
				ep.setCar_model_name(rs.getString("car_model_name"));
				ep.setCar_model_number(rs.getInt("car_model_number"));
				ep.setRent_money(rs.getDouble("rent_money"));
				ep.setCar_model_seating(rs.getInt("car_model_seating"));
				ep.setCar_model_type(rs.getString("car_model_type"));
				ep.setCar_model_door_number(rs.getInt("car_model_door_number"));
				ep.setCar_model_fuel_type(rs.getString("car_model_fuel_type"));
				ep.setCar_model_image(rs.getString("car_model_image"));
				ep.setCompany_discount(rs.getDouble("company_discount"));
				
				return ep;
			}
		};
		
		return queryList(sql, new ParamSet(id),rd);
	}
}
